#include <stdio.h>
#include <stdlib.h>

typedef short int bool;
#define true    1
#define false   0

#define M   100
#define MAX 1000


short int mat[M][M] = {{0}};
short int s[2][M] = {{0}};
short int d[M] = {0};
int n = 0;
int costtime = 0;

void initmat()
{
    int i = 0, j = 0;

    for(i = 0; i < M; i++)
    {
        for(j = 0; j < M; j++)
        {
            mat[i][j] = MAX;
        }
    }
}

void showmat()
{
    int i = 0, j = 0;

    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        {
            printf("%d\t", mat[i][j]);
        }
        printf("\n");
    }
}

void inits(int k)
{
    int i = 0, j = 0;

    s[0][j] = k;
    s[1][j] = 0;
    j++;
    for(i = 0; i <= k-1; i++)
    {
        s[0][j] = i;
        s[1][j] = mat[k][i];
        j++;

    }
    for(i = k+1; i < n; i++)
    {
        s[0][j] = i;
        s[1][j] = mat[k][i];
        j++;
    }
}

bool testover()
{
    int i = 0;

    for(i = 0; i < n; i++)
    {
        if(s[1][i] != 0)
        {
            return false;
        }
    }
    return true;
}

bool findmin(int* min, int* v)
{
    int i = 0;

    *min = MAX;
    *v   = -1;

    for(i = 1; i < n; i++)
    {
        if(s[1][i] == 0)
        {
            continue;
        }
        if(*min > s[1][i])
        {
            *min = s[1][i];
            *v   = s[0][i];
        }
    }
    return *min == MAX ? false : true;
}

void calcu(int v)
{
    int i = 0;
    int v0 = -1;
    for(i = 0; i < n; i++)
    {
        if(s[1][i] == 0)
        {
            continue;
        }
        v0 = s[0][i];
        if(s[1][i] > mat[v][v0])
        {
            s[1][i] = mat[v][v0];
        }
    }
}

void shows()
{
    int i = 0;

    for(i = 0; i < n; i++)
    {
        printf("%d\t", s[0][i]);
    }
    printf("\n");
    for(i = 0; i < n; i++)
    {
        printf("%d\t", s[1][i]);
    }
    printf("\n");
}

int fn()
{
    int i = 0;
    int min = 0, v = 0;

    //shows();

    if(testover() == true)
    {
        return costtime;
    }

    if(findmin(&min, &v) == false)
    {
        return MAX;
    }
    for(i = 0; i < n; i++)
    {
        if(s[1][i] == 0 || s[1][i] == MAX)
        {
            continue;
        }
        s[1][i] -= min;
    }
    costtime += min;
    calcu(v);
    return fn();
}

void process()
{
    int i = 0, v = 0;
    int min = MAX, temp = 0;

    //showmat();


    for(i = 0; i < n; i++)
    {
        costtime = 0;
        inits(i);
        temp = fn();
        if(min > temp)
        {
            min = temp;
            v = i;
        }
    }
    if(min == MAX)
    {
        printf("disjoint\n");
    }
    else
    {
        printf("%d %d\n", v+1, min);
    }
}

int main()
{
    //freopen("bin\\debug\\in.txt", "r", stdin);
    int i = 0, j = 0, k = 0;
    int vb = 0, ve = 0, t = 0;

    while(1)
    {
        initmat();
        scanf("%d", &n);
        if(n == 0)
        {
            break;
        }
        for(i = 0, vb = 1; i < n; i++, vb++)
        {
            scanf("%d", &k);
            for(j = 0; j < k; j++)
            {
                scanf("%d %d", &ve, &t);
                mat[vb-1][ve-1] = t;
            }
        }

        process();
    }


    return 0;
}
